<template>
  <div class="card-bar-container">
    <el-card
      v-for="item in countData"
      :key="item.id"
      :body-style="{ padding: 0 }"
    >
      <i
        class="icon"
        :class="`el-icon-${item.icon}`"
        :style="{ background: item.color }"
      ></i>
      <div>
        <h4># {{ item.value }}</h4>
        <p>{{ item.name }}</p>
      </div>
    </el-card>
  </div>
</template>

<script>
import { getCard } from "@/api/home";
export default {
  name: "cardBar",

  data() {
    return {
      countData: [],
    };
  },

  mounted() {
    getCard().then((res) => {
      if (res.status !== 200) {
        return this.$message.error("获取卡片数据失败！！");
      } else {
        return (this.countData = res.data.countData);
      }
    });
  },

  methods: {},
};
</script>

<style lang="less" scoped>
.card-bar-container {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
}
.el-card {
  width: 30%;
  height: 60px;
  margin: 5px 15px;
  .icon {
    float: left;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    font-size: 40px;
    width: 20%;
    height: 60px;
  }
  div {
    float: left;
    > h4 {
      margin: 5px 30px;
      padding: 0;
      font-size: 22px;
    }
    > p {
      margin: 0 35px;
      padding: 0;
      font-size: 10px;
    }
  }
}
</style>